import { ChannelConfig } from "../src/config/ChannelConfig";
import { HttpUtil } from "../src/engine/utils/HttpUtil";

const APP_ID: string = "wxa16c47ab675b6edb"
const AppSecret: string = "c34de2f3a114c67ae3fbfc178f7f61cc"

// com.g1ame.dajialejingji
// const APP_ID: string = "wx2b30957daca6d855"
// const AppSecret: string = "5dc1046cb482a7676ce9c6ecc802c364"

export class WechatSdkManager {

    public static instance: WechatSdkManager = new WechatSdkManager();


    public get_access_token(code: string, callback: Function = null) {
        let data = {
            "appid": APP_ID,
            "secret": AppSecret,
            "code": code,
            grant_type: "authorization_code"
        };
        HttpUtil.request_by_form("https://api.weixin.qq.com/sns/oauth2/access_token", data, callback)
    }

    public get_userinfo(access_token: string, openid: string, callback: Function = null) {
        let data = {
            access_token: access_token,
            openid: openid
        };
        HttpUtil.request_by_form("https://api.weixin.qq.com/sns/userinfo", data, callback)
    }
}